package com.neusoft.bizcore.webauth.secret;

import java.util.Arrays;
import java.util.List;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "bizcore.webauth", ignoreUnknownFields = false)
public class BizcoreWebAuthProperties {

    private long jwtExpiration = 86400000000L;
    private String jwtSigningKey = "secret";

    private String usernameParameter = "username";
    private String passwordParameter = "password";
    private String loginProcessingUrl = "/login";
    private String logoutProcessingUrl = "/logout";
    private List<String> permitAll =
            Arrays.asList("/", "/login", "/dinglogin", "/auth/api/w/auth/users/anonymous", "/websocket/**");

    private List<String> ignores =
            Arrays.asList("/favicon.ico", "/static/**", "/css/**", "/js/**", "/assets/**", "/fonts/**");
    private String authServiceName = "auth";

    private final Cas cas = new Cas();
    private final Ding ding = new Ding();
    private final OAuth2 oauth2 = new OAuth2();

    @Getter
    @Setter
    public static class Cas {
        private boolean enabled = false;
        private String processingUrl = "/cas";
        private String homeUrl = "http://localhost:9527";
        private String serverUrl = "http://localhost:8080/cas/login";
        private String validateStUrl = "http://localhost:8080/cas/serviceValidate";

    }

    @Getter
    @Setter
    public static class Ding {
        private String authcodeParameter = "authCode";
        private String loginProcessingUrl = "/dinglogin";
    }

    @Getter
    @Setter
    public static class OAuth2 {
        private String authcodeParameter = "code";
        private String loginProcessingUrl = "/oauth2login";
    }

}
